package com.luych.toolbox.common.feign.intf.gateway.center;

import com.luych.toolbox.common.feign.param.gateway.center.WebSocketChat;
import com.luych.toolbox.common.feign.param.gateway.center.WebSocketLetter;
import com.luych.toolbox.common.feign.param.gateway.center.WebSocketNotice;
import com.luych.toolbox.common.feign.param.gateway.center.WebSocketTask;
import com.luych.toolbox.common.feign.view.gateway.center.WebSocketSession;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(contextId = "gateway-center-websocket", name = "gateway-center", path = "/api/websocket", decode404 = true)
public interface WebSocketFeign {

    @ApiOperation("获取WebSocket连接")
    @GetMapping
    List<WebSocketSession> get();

    @ApiOperation("发送消息通知")
    @PostMapping(path = "{userId}/notice")
    ResponseEntity<?> notice(
            @ApiParam("用户ID") @PathVariable("userId") String userId,
            @ApiParam("消息内容") @RequestBody WebSocketNotice webSocketNotice
    );

    @ApiOperation("发送站内信")
    @PostMapping(path = "{userId}/letter")
    ResponseEntity<?> letter(
            @ApiParam("用户ID") @PathVariable("userId") String userId,
            @ApiParam("消息内容") @RequestBody WebSocketLetter webSocketLetter
    );

    @ApiOperation("发送及时消息")
    @PostMapping(path = "{userId}/chat")
    ResponseEntity<?> chat(
            @ApiParam("用户ID") @PathVariable("userId") String userId,
            @ApiParam("消息内容") @RequestBody WebSocketChat webSocketChat
    );

    @ApiOperation("发送任务")
    @PostMapping(path = "{userId}/task")
    ResponseEntity<?> task(
            @ApiParam("用户ID") @PathVariable("userId") String userId,
            @ApiParam("消息内容") @RequestBody WebSocketTask webSocketTask
    );

    @ApiOperation("关闭WebSocket连接")
    @DeleteMapping(path = "{userId}")
    ResponseEntity<?> close(@ApiParam("用户ID") @PathVariable("userId") String userId);

}
